from App_SearchNovel.models import Books


def ParseBook(all):
    data = []
    if all is not None:
        for i in all:
            data.append(
                {"bookid": i.bookid, "title": i.title, "author": i.author, "category": i.category, "profile": i.profile,
                 "nice": i.nice})
        return data
    return None

def parseWord(all):
    data = []
    if all is not None:
        for i in all:
            Books.objects.get(bookid=i.bookid).title
            data.append(
                {"id":i.id,"word": i.word, "mean": i.mean,"title":Books.objects.get(bookid=i.bookid).title})
        return data
    return None

def isLogin(request):
    print(request.session.get("islogin", False))
    return request.session.get("islogin", False)
